﻿using MonoRailDemo.Models;
using System.Collections.Generic;
public class XmlPollRepository : IPollRepository
{
    #region IPollRepository Members
    private static Dictionary<int, Poll> db = new Dictionary<int, Poll>();
    public void Add(string question, System.Collections.Generic.IEnumerable<string> answers)
    {
        Poll poll = new Poll { Answers = answers, Question = question, Id = db.Count + 1 };
        db[poll.Id] = poll;
    }

    public Poll GetPoll(int pollId)
    {
        Poll poll;
        if (db.TryGetValue(pollId, out poll))
        {
            return poll;
        }
        return null;
    }

    #endregion

    #region IPollRepository Members


    public IEnumerable<Poll> GetAllPolls()
    {
        return db.Values;
    }

    #endregion
}
